summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorliamwhite <liamwhite@users.noreply.github.com>2024-01-04 21:50:47 +0100
committerGitHub <noreply@github.com>2024-01-04 21:50:47 +0100
commitd7e7a69e00c254a2a641c3d0f23e38f774177cb8 (patch)
tree630e953e587de650802b58b545a9105b28ed7abf
parentMerge pull request #12557 from merryhime/termination-ipi (diff)
parentandroid: Add internal option to disable compression for zip exports (diff)
downloadyuzu-d7e7a69e00c254a2a641c3d0f23e38f774177cb8.tar
yuzu-d7e7a69e00c254a2a641c3d0f23e38f774177cb8.tar.gz
yuzu-d7e7a69e00c254a2a641c3d0f23e38f774177cb8.tar.bz2
yuzu-d7e7a69e00c254a2a641c3d0f23e38f774177cb8.tar.lz
yuzu-d7e7a69e00c254a2a641c3d0f23e38f774177cb8.tar.xz
yuzu-d7e7a69e00c254a2a641c3d0f23e38f774177cb8.tar.zst
yuzu-d7e7a69e00c254a2a641c3d0f23e38f774177cb8.zip
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/GamePropertiesFragment.kt3
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt3
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/FileUtil.kt12
3 files changed, 15 insertions, 3 deletions
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/GamePropertiesFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/GamePropertiesFragment.kt
index b1d3c0040..b04d1208f 100644
--- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/GamePropertiesFragment.kt
+++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/GamePropertiesFragment.kt
@@ -445,7 +445,8 @@ class GamePropertiesFragment : Fragment() {
val zipResult = FileUtil.zipFromInternalStorage(
File(saveLocation),
saveLocation.replaceAfterLast("/", ""),
- BufferedOutputStream(requireContext().contentResolver.openOutputStream(result))
+ BufferedOutputStream(requireContext().contentResolver.openOutputStream(result)),
+ compression = false
)
return@newInstance when (zipResult) {
TaskState.Completed -> getString(R.string.export_success)
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt
index b4117d761..622ae996e 100644
--- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt
+++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt
@@ -625,7 +625,8 @@ class MainActivity : AppCompatActivity(), ThemeProvider {
File(DirectoryInitialization.userDirectory!!),
DirectoryInitialization.userDirectory!!,
BufferedOutputStream(contentResolver.openOutputStream(result)),
- taskViewModel.cancelled
+ taskViewModel.cancelled,
+ compression = false
)
return@newInstance when (zipResult) {
TaskState.Completed -> getString(R.string.user_data_export_success)
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/FileUtil.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/FileUtil.kt
index 00c6bf90e..132f002fb 100644
--- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/FileUtil.kt
+++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/FileUtil.kt
@@ -21,6 +21,7 @@ import org.yuzu.yuzu_emu.model.TaskState
import java.io.BufferedOutputStream
import java.lang.NullPointerException
import java.nio.charset.StandardCharsets
+import java.util.zip.Deflater
import java.util.zip.ZipOutputStream
import kotlin.IllegalStateException
@@ -312,15 +313,23 @@ object FileUtil {
* @param inputFile File representation of the item that will be zipped
* @param rootDir Directory containing the inputFile
* @param outputStream Stream where the zip file will be output
+ * @param cancelled [StateFlow] that reports whether this process has been cancelled
+ * @param compression Disables compression if true
*/
fun zipFromInternalStorage(
inputFile: File,
rootDir: String,
outputStream: BufferedOutputStream,
- cancelled: StateFlow<Boolean>? = null
+ cancelled: StateFlow<Boolean>? = null,
+ compression: Boolean = true
): TaskState {
try {
ZipOutputStream(outputStream).use { zos ->
+ if (!compression) {
+ zos.setMethod(ZipOutputStream.DEFLATED)
+ zos.setLevel(Deflater.NO_COMPRESSION)
+ }
+
inputFile.walkTopDown().forEach { file ->
if (cancelled?.value == true) {
return TaskState.Cancelled
@@ -338,6 +347,7 @@ object FileUtil {
}
}
} catch (e: Exception) {
+ Log.error("[FileUtil] Failed creating zip file - ${e.message}")
return TaskState.Failed
}
return TaskState.Completed